package io.github.eiot.charge.ykc.data;

import io.github.eiot.annotation.Frame;
import io.github.eiot.annotation.FrameField;
import io.github.eiot.codec.BCD;
import io.github.eiot.codec.NumberUnit;

/**
 * Bms充电结束 0x19
 *
 * @author yan
 * @since 2025-09-06
 */
@Frame
public class YkcBmsChargeEnd implements YkcHasTerminalNo, YkcHasGunNo {

    /**
     * 交易流水号 BCD码 16
     */
    @FrameField(len = 16)
    private BCD orderNo;

    /**
     * 桩编号 BCD码 7
     */
    @FrameField(len = 7)
    private BCD terminalNo;

    /**
     * 枪号 BIN码 1
     */
    @FrameField(len = 1)
    private int gunNo;

    /**
     * BMS 中止前电状态 SOC BIN码 1
     * 1%/位，0%偏移量；数据范围：0~100%
     */
    @FrameField(len = 1)
    private int soc;

    /**
     * BMS 动力蓄电池单体最低电压 BIN码 2
     * 0.01 V/位，0 V 偏移量；数据范围：0~24 V
     */
    @FrameField(len = 2, unit = 100)
    private NumberUnit cellMinV;

    /**
     * BMS 动力蓄电池单体最高电压 BIN码 2
     * 0.01 V/位，0 V 偏移量；数据范围：0~24 V
     */
    @FrameField(len = 2, unit = 100)
    private NumberUnit cellMaxV;

    /**
     * BMS 动力蓄电池最低温度 BIN码 1
     * 1°C/位，-50 °C 偏移量；数据范围：-50 ~ +200 °C
     */
    @FrameField(len = 1, offset = -50)
    private int minTemp;

    /**
     * BMS 动力蓄电池最高温度 BIN码 1
     * 1°C/位，-50 °C 偏移量；数据范围：-50 ~ +200 °C
     */
    @FrameField(len = 1, offset = -50)
    private int maxTemp;

    /**
     * 电桩累计充电时间 BIN码 2
     * 1 min/位，0 min 偏移量；数据范围：0~600 min
     */
    @FrameField(len = 2)
    private int totalChargingTime;

    /**
     * 电桩输出能量 BIN码 2
     * 0.1 kWh/位，0 kWh 偏移量；数据范围：0~1000 kWh
     */
    @FrameField(len = 2, unit = 10)
    private NumberUnit totalPower;

    /**
     * 电桩充电机编号 BIN码 4
     * 充电机编号，1/位，1 偏移量；数据范围：0 ~ 0xFFFFFFF
     */
    @FrameField(len = 4)
    private int chargerSn;

    /**
     * getter auto generated
     */
    public BCD getOrderNo() {
        return orderNo;
    }

    /**
     * setter auto generated
     */
    public void setOrderNo(BCD orderNo) {
        this.orderNo = orderNo;
    }

    /**
     * setter auto generated
     */
    public void setOrderNo(String orderNo) {
        io.github.eiot.utils.ValidationUtil.lteLen(orderNo, 32, orderNo);
        this.orderNo = BCD.from(orderNo, 32);
    }

    /**
     * getter auto generated
     */
    public BCD getTerminalNo() {
        return terminalNo;
    }

    /**
     * setter auto generated
     */
    public void setTerminalNo(BCD terminalNo) {
        this.terminalNo = terminalNo;
    }

    /**
     * setter auto generated
     */
    public void setTerminalNo(String terminalNo) {
        io.github.eiot.utils.ValidationUtil.lteLen(terminalNo, 14, terminalNo);
        this.terminalNo = BCD.from(terminalNo, 14);
    }

    /**
     * getter auto generated
     */
    public int getGunNo() {
        return gunNo;
    }

    /**
     * setter auto generated
     */
    public void setGunNo(int gunNo) {
        this.gunNo = gunNo;
    }

    /**
     * getter auto generated
     */
    public int getSoc() {
        return soc;
    }

    /**
     * setter auto generated
     */
    public void setSoc(int soc) {
        this.soc = soc;
    }

    /**
     * getter auto generated
     */
    public NumberUnit getCellMinV() {
        return cellMinV;
    }

    /**
     * setter auto generated
     */
    public void setCellMinV(NumberUnit cellMinV) {
        this.cellMinV = cellMinV;
    }

    /**
     * setter auto generated
     */
    public void setCellMinV(double cellMinV) {
        this.cellMinV = NumberUnit.from(cellMinV, 100);
    }

    /**
     * getter auto generated
     */
    public NumberUnit getCellMaxV() {
        return cellMaxV;
    }

    /**
     * setter auto generated
     */
    public void setCellMaxV(NumberUnit cellMaxV) {
        this.cellMaxV = cellMaxV;
    }

    /**
     * setter auto generated
     */
    public void setCellMaxV(double cellMaxV) {
        this.cellMaxV = NumberUnit.from(cellMaxV, 100);
    }

    /**
     * getter auto generated
     */
    public int getMinTemp() {
        return minTemp;
    }

    /**
     * setter auto generated
     */
    public void setMinTemp(int minTemp) {
        this.minTemp = minTemp;
    }

    /**
     * getter auto generated
     */
    public int getMaxTemp() {
        return maxTemp;
    }

    /**
     * setter auto generated
     */
    public void setMaxTemp(int maxTemp) {
        this.maxTemp = maxTemp;
    }

    /**
     * getter auto generated
     */
    public int getTotalChargingTime() {
        return totalChargingTime;
    }

    /**
     * setter auto generated
     */
    public void setTotalChargingTime(int totalChargingTime) {
        this.totalChargingTime = totalChargingTime;
    }

    /**
     * getter auto generated
     */
    public NumberUnit getTotalPower() {
        return totalPower;
    }

    /**
     * setter auto generated
     */
    public void setTotalPower(NumberUnit totalPower) {
        this.totalPower = totalPower;
    }

    /**
     * setter auto generated
     */
    public void setTotalPower(double totalPower) {
        this.totalPower = NumberUnit.from(totalPower, 10);
    }

    /**
     * getter auto generated
     */
    public int getChargerSn() {
        return chargerSn;
    }

    /**
     * setter auto generated
     */
    public void setChargerSn(int chargerSn) {
        this.chargerSn = chargerSn;
    }
}
